package com.xjrsoft.module.customerTwo.ycode.t_ycode_label_printing_record.service.impl;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.xjrsoft.core.tool.utils.StringUtil;
import com.xjrsoft.module.customerTwo.ycode.t_ycode_label_printing_record.entity.TYcodeLabelPrintingRecord;
import com.xjrsoft.module.customerTwo.ycode.t_ycode_label_printing_record.dto.TYcodeLabelPrintingRecordListDto;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.xjrsoft.common.page.ConventPage;
import com.xjrsoft.common.page.PageOutput;
import java.util.List;
import com.xjrsoft.module.customerTwo.ycode.t_ycode_label_printing_record.mapper.TYcodeLabelPrintingRecordMapper;
import com.xjrsoft.module.customerTwo.ycode.t_ycode_label_printing_record.service.ITYcodeLabelPrintingRecordService;
import com.xjrsoft.core.mp.base.BaseService;
import com.xjrsoft.core.tool.utils.Func;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.metadata.IPage;

/**
 *  服务实现类
 *
 * @author dongxinhang
 * @since 2024-08-07
 */
@Service
@AllArgsConstructor
public class TYcodeLabelPrintingRecordServiceImpl extends BaseService<TYcodeLabelPrintingRecordMapper, TYcodeLabelPrintingRecord> implements ITYcodeLabelPrintingRecordService {


	@Override
	public IPage<TYcodeLabelPrintingRecord> getPageList(TYcodeLabelPrintingRecordListDto pageListDto) {
		Wrapper<TYcodeLabelPrintingRecord> wrapper = Wrappers.<TYcodeLabelPrintingRecord>query().lambda()
				.like(!StringUtil.isEmpty(pageListDto.getProduct_name()), TYcodeLabelPrintingRecord::getProductName, pageListDto.getProduct_name())
				.like(!StringUtil.isEmpty(pageListDto.getProduct_internal_code()), TYcodeLabelPrintingRecord::getProductInternalCode, pageListDto.getProduct_internal_code());
		return this.page(ConventPage.getPage(pageListDto), wrapper);
	}

	@Override
	public boolean addTYcodeLabelPrintingRecord(TYcodeLabelPrintingRecord tYcodeLabelPrintingRecord) {
		boolean isSuccess = this.save(tYcodeLabelPrintingRecord);
		return isSuccess;
	}

	@Override
	public boolean updateTYcodeLabelPrintingRecord(String id, TYcodeLabelPrintingRecord tYcodeLabelPrintingRecord) {
		tYcodeLabelPrintingRecord.setId(id);
		return this.updateById(tYcodeLabelPrintingRecord);
	}

	public boolean delete(String ids) {
		List<String> idList = Func.toStrList(ids);
		if (this.removeByIds(idList)) {
			return true;
		}
		return false;
	}

}